from rest_framework.routers import SimpleRouter
from rest_framework_jwt.views import obtain_jwt_token

from django.conf.urls import url

from apps.goods.models import SPUSpecification
from apps.meiduo_admin.views import data, users
from apps.meiduo_admin.views.sku import SKUView, ThirdCategoryView
from apps.meiduo_admin.views.specs import SpecsView, SPUSpecView
from apps.meiduo_admin.views.spu import SpuView

urlpatterns = [
    # 后台主页
    url('^authorizations/$', obtain_jwt_token),
    # 总用户
    url('^statistical/total_count/$', data.UserTotalCountView.as_view()),
    # 日增长用户
    url('^statistical/day_increment/$', data.UserDayCountView.as_view()),
    # 日活跃度
    url('^statistical/day_active/$', data.UserActiveCountView.as_view()),
    #  日下单
    url('^statistical/day_orders/$', data.UserOrderCountView.as_view()),
    # 月增用户
    url('^statistical/month_increment/$', data.UserMonthCountView.as_view()),
    # 日分类商品统计
    url('^statistical/goods_day_views/$', data.GoodsDayView.as_view()),
    # 查询所有用户
    url('^users/$', users.UserView.as_view()),
    # 商品下拉菜单
    url(r'^goods/simple/$', SpuView.as_view()),
    # 三级分类名
    url(r'^skus/categories/$', ThirdCategoryView.as_view()),

    #获取规格信息
    url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecView.as_view()),


]

# 动态添加路由
router = SimpleRouter()
router.register('goods/specs', SpecsView, 'specs')
router.register('skus', SKUView, 'skus')
urlpatterns += router.urls
